Setup nginx repo:
  file.managed:
    - name: /etc/yum.repos.d/nginx.repo
    - source: salt://nginx/files/nginx.repo

Setup nginx:
  group.present:
    - name: nginx
    - gid: 99999

  user.present:
    - name: nginx
    - shell: /sbin/nologin
    - uid: 99999
    - gid: 99999
    - unique: false
    - unless: test -f /etc/nginx/nginx.conf

  pkg.installed:
    - pkgs:
      - nginx
    - unless: test -f /etc/nginx/nginx.conf


Copy default nginx config nginx.conf:
  file.managed:
    - name: /etc/nginx/nginx.conf
    - source: salt://app/training/files/nginx.conf
    - template: jinja

Copy jenkins.conf:
  file.managed:
    - name: /etc/nginx/conf.d/jenkins.conf
    - source: salt://jenkins2/files/nginx.jenkins.conf.jinja
    - template: jinja

Enable nginx service:
  service.running:
    - name: nginx
    - enable: True
    - listen:
      - file: /etc/nginx/nginx.conf